<?php

require_once(OC_App::getAppPath('jobposition') . "/lib/position.php");
JLoader::register("UserPrivacy", JPATH_SITE.'/components/com_puser/userprivacy.php');

OCP\JSON::callCheck();
if(!OC_User::isLoggedIn()) {
   echo '您需要先登录';
   exit;
}

$jobid = JRequest::getInt('jobid', 0);

$model = new PJobpositionModelPosition();
$item = $model->showJobdetails($jobid);

if(empty($item)) {
   echo '职位不存在';
   exit;
}
$lang = PFactory::getLanguage();
$lang->load("com_jobs", JPATH_SITE, "zh-CN");

$user = JobHelper::getEmployerProfileDetails($item->employer_id, true);
UserPrivacy::getUserPrivacySettings($user, 'com_company');
$me = PFactory::getUser();

?>

<div class="jos_lptitle yahei"><?=$item->job_title?><span class="songti">(<?=$item->companyname?>)</span></div>
<table class="medium" width="100%" border="0" cellpadding="0" cellspacing="0">
   <tr>
      <td width="50%">工作城市：<?php echo ($item->state || $item->city) ? ($item->state == $item->city ? $item->state : $item->state.' '.$item->city) : '不限'; ?></td>
      <td width="50%">工作职能：<?php echo $item->position ? $item->position : '未设置' ; ?></td>
   </tr>
   <tr>
      <td>工作经验：<?php echo $item->exp_name ? JText::_($item->exp_name) : '不限' ; ?></td>
      <td>月薪范围：<?php echo $item->salary_type ? JText::_($item->salary_type) : '不限' ; ?></td>
   </tr>
   <tr>
      <td>招聘人数：<?=$item->num_needed ? $item->num_needed : '若干'; ?></td>
   </tr> 
   <tr>
      <?php
         $phonefieldname = "contactname";
         $phoneprivacy = UserPrivacy::checkFieldPrivacy($user, $me, $phonefieldname);
         if($phoneprivacy){
            $phoneprivacy_value=UserPrivacy::getUserPrivacyFieldSetting($user,$phonefieldname);
            if($phoneprivacy_value->privacy==USER_PRIVACY_PUBLIC){
      ?>
      <td>联&nbsp;&nbsp;系&nbsp;&nbsp;人：<?=$user->contact_name ? $user->contact_name : '暂无'?></td>
     <?php 
            }
         }
     ?>
   
      <?php
         $phonefieldname = "telephone";
         $phoneprivacy = UserPrivacy::checkFieldPrivacy($user, $me, $phonefieldname);
         if($phoneprivacy){
            $phoneprivacy_value=UserPrivacy::getUserPrivacyFieldSetting($user,$phonefieldname);
            if($phoneprivacy_value->privacy==USER_PRIVACY_PUBLIC){
      ?>
      <td>联系电话：<?=$user->phone ? $user->phone : '暂无'?></td>
      <?php 
            }
         }
      ?>
   </tr>

</table>
<div class="jos_lpdescription"><b>职位描述</b></div>
<div class="jos_lpcontent medium">
   <?=$item->long_desc ? htmlspecialchars_decode(nl2br($item->long_desc)) : '暂无'?>
</div>
